package com.abc.controller;


import com.abc.entity.ProgramType;
import com.abc.service.IProgramTypeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2024-12-25
 */
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/programType")
@Api(tags = "节目类型管理")
public class ProgramTypeController {
    @Autowired
    private IProgramTypeService programTypeService;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID获取节目类型", notes = "传入节目的类型ID")
    public ProgramType getProgramTypeById(@PathVariable Integer id) {
        return programTypeService.getById(id);
    }

    @PostMapping
    @ApiOperation(value = "添加节目类型", notes = "传入节目的类型详细信息")
    public boolean addProgramType(@RequestBody ProgramType programType) {
        return programTypeService.save(programType);
    }

    @PutMapping
    @ApiOperation(value = "更新节目类型", notes = "传入节目的类型详细信息")
    public boolean updateProgramType(@RequestBody ProgramType programType) {
        return programTypeService.updateById(programType);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除节目类型", notes = "传入节目的类型ID")
    public boolean deleteProgramType(@PathVariable Integer id) {
        return programTypeService.removeById(id);
    }
}
